﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GeoWeb.DataContext;

namespace GeoWeb.Demo.ButtonConfigInfo
{
    public class MenuTreeDal : GeoWeb.Demo.DataContext.DbUtity
    {
        /// <summary>
        /// 获取所有的顶级菜单信息
        /// </summary>
        /// <returns></returns>
        public List<GeoMenuTree> GetMenuTreeList()
        {
            return Db.From<GeoMenuTree>().Where(GeoMenuTree._.ParentOID.IsNull()).OrderBy(GeoMenuTree._.pxm.Asc).ToList<GeoMenuTree>() as List<GeoMenuTree>;
        }
        /// <summary>
        /// 获取ID下所有菜单信息
        /// </summary>
        /// <returns></returns>
        public List<GeoMenuTree> GetMenuTreeList(Guid ID)
        {
            return Db.From<GeoMenuTree>().Where(GeoMenuTree._.ParentOID==ID).OrderBy(GeoMenuTree._.pxm.Asc).ToList<GeoMenuTree>() as List<GeoMenuTree>;
        }
        /// <summary>
        /// 根据ID获取菜单信息
        /// </summary>
        /// <returns></returns>
        public GeoMenuTree Select(Guid ID)
        {
            return Db.From<GeoMenuTree>().Where(GeoMenuTree._.MenuTreeOID == ID).ToSingle<GeoMenuTree>();
        }
    }
}